home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1595 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: erich.triumf.ca!bennett
  2. From: bennett@erich.triumf.ca (P.Bennett)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: directories listing
  5. Date: 15 Jan 1996 07:58 PST
  6. Organization: TRIUMF: Tri-University Meson Facility
  7. Distribution: world
  8. Message-ID: <15JAN199607581827@erich.triumf.ca>
  9. References: <4dckfq$4um@news.ust.hk>
  10. NNTP-Posting-Host: ftp.triumf.ca
  11. News-Software: VAX/VMS VNEWS 1.50    
  12.  
  13. In article <4dckfq$4um@news.ust.hk>, cs_lcm@ug.cs.ust.hk (Lee Chun Man Raymond) writes...
  14. >Hi,
  15. >    I wrote a C program that needs to print out a listing of  
  16. >sub-directories of current working directory.
  17. >The following is part of my program : ( Turbo C++ )
  18. >struct find_t current_file;
  19. >int done; 
  20. >..........
  21. >printf("Directories listing : \n");
  22. >done = _dos_findfirst(full_path , FA_DIREC, ¤t_file); 
  23. >while (!done) {
  24. >   strcpy(file_path, path_name);
  25. >   strcat(file_path, "\\");
  26. >   strcat(file_path, current_file.name)
  27. >   printf("--> %s\n",file_path);
  28. >   done = _dos_findnext(¤t_file);
  29. >} 
  30. >I don't know why it lists out all file including the sub-directories, but
  31. >I only want to lists our those sub-directories.
  32.  
  33. The DOS service called  by _dos_findfirst (and findnext) returns all _normal_
  34. files, _plus_ any having the attributes you specify.  To list the directories
  35. only, you have to test the attributes of each returned file, and ignore any
  36. that are not what you want.
  37.  
  38. Peter Bennett VE7CEI                | Vessels shall be deemed to be in sight
  39. Internet: bennett@triumf.ca         | of one another only when one can be
  40. Packet: ve7cei@ve7kit.#vanc.bc.ca   | observed visually from the other
  41. TRIUMF, Vancouver, B.C., Canada     |                          ColRegs 3(k)
  42. GPS and NMEA info and programs: ftp://sundae.triumf.ca/pub/peter/index.html
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.